home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 147
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan).7z
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan) (Track 1).bin
/
tools
/
ex68v209
/
ex68v209.lzh
/
X6_UTIL.LZH
/
READFD.C
< prev
next >
Wrap
C/C++ Source or Header
|
1998-10-09
|
2KB
|
102 lines
#include <stdio.h>
#include <iocslib.h>
#include <stdlib.h>
#include <string.h>
#include <basic.h>
int drive_num=0;
int start_trk=0;
int end_trk=77;
char file_name[256];
int chk_arg(int argc,char **argv)
{
int i,j;
char abuff[256];
for(i=1; i<argc; i++)
{
strcpy(abuff,argv[i]);
for(j=1; j<strlen(abuff); j++)
abuff[j]=tolower(abuff[j]);
if (abuff[0]=='/')
abuff[0]='-';
if (!strncmp(abuff,"-h",2))
{
printf("readfd.x -d[0|1] -f[file] -s[0..76] -e[1..77]\n");
printf(" -d[0|1] ドライブ番号指定 デフォルト(0) \n");
printf(" -f[file] 出力ファイル名 (FD0.XDF)\n");
printf(" -s[0..76] 開始トラック (0) \n");
printf(" -e[1..77] 終了トラック (77) \n");
exit(1);
}
if (strlen(abuff)<3)
{
printf("option error (%s)\n",abuff);
return 1;
}
if (!strncmp(abuff,"-d",2))
{
drive_num=atoi(&abuff[2]);
if ((drive_num<0) || (drive_num>3))
drive_num=0;
}
else if (!strncmp(abuff,"-f",2))
{
strcpy(file_name,&abuff[2]);
}
else if (!strncmp(abuff,"-s",2))
{
start_trk=atoi(&abuff[2]);
if ((start_trk<0) || (start_trk>80))
start_trk=0;
}
else if (!strncmp(abuff,"-e",2))
{
end_trk=atoi(&abuff[2]);
if ((end_trk<0) || (end_trk>80))
start_trk=77;
}
else
{
printf("option error (%s)\n",abuff);
return 1;
}
}
return 0;
}
void main(int argc,char **argv)
{
int sect,side,track,res;
char buff[1024*8];
FILE *fp;
printf("readfd.x v1.1\n");
strcpy(file_name,"FD0.XDF");
if (chk_arg(argc,argv))
exit(1);
fp=fopen(file_name,"wb");
for(track=start_trk; track<end_trk; track++)
for(side=0; side<2; side++)
{
sect=1;
printf("track %2d side %d .. \r",track,side);
res=B_READ(0x9070+(drive_num<<8),
((((((3<<8)+track)<<8)+side)<<8)+sect),1024*8,buff);
if ((res&0xffffff00)==0xffffff00)
{
printf("read error!\n");
exit(1);
}
fwrite(buff,1,1024*8,fp);
}
if (fclose(fp))
{
printf("\write error!\n");
exit(1);
}
printf("\n\n");
}